package c6132.Day3;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class Testdatabase {
    public static void main(String[] args) {
        //2,获取连接-得到connection
        try {
            Connection conn= JUtil.getConn();
            //3,创建执行SQL语句的对象
            Statement st = conn.createStatement();
            String sql="insert into student(name,age) values ('小白',20)";
            //4,执行增删改查中的插入
            int i=st.executeUpdate(sql);
            System.out.println(i);

            //5,释放资源-关闭相关的连接
            JUtil.free(st,conn);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
